
$logFile = [String]::Format('{0}\{1}', $env:BTAD_InstallDir, 'Deployment\Sixeyed.CacheAdapterSample.Install.ps1.log')
[IO.File]::Delete($logFile)
[IO.File]::AppendAllText($logFile, [String]::Format('Installation started: {0}{1}', [DateTime]::Now, [Environment]::NewLine))

[IO.File]::AppendAllText($logFile, 'Creating FILE receive locations')
[IO.File]::AppendAllText($logFile, [Environment]::NewLine)

new-item 'c:\drops\SimpleMessaging\requests' -itemtype Directory -force
new-item 'c:\drops\ComplexMessaging\requests' -itemtype Directory -force
new-item 'c:\drops\Orchestration\requests' -itemtype Directory -force

[IO.File]::AppendAllText($logFile, 'Copying sample message to receive locations')
[IO.File]::AppendAllText($logFile, [Environment]::NewLine)

$sampleMessagePath = [String]::Format('{0}\{1}', $env:BTAD_InstallDir, 'SampleMessages\GetServerDateTime_request.xml')
copy-item $sampleMessagePath -destination c:\drops\SimpleMessaging\requests -force
copy-item $sampleMessagePath -destination c:\drops\ComplexMessaging\requests -force
copy-item $sampleMessagePath -destination c:\drops\Orchestration\requests -force

[IO.File]::AppendAllText($logFile, 'Creating FILE send locations')
[IO.File]::AppendAllText($logFile, [Environment]::NewLine)

new-item c:\drops\SimpleMessaging\responses -itemtype Directory -force
new-item c:\drops\ComplexMessaging\responses -itemtype Directory -force
new-item c:\drops\Orchestration\responses -itemtype Directory -force

[IO.File]::AppendAllText($logFile, 'Importing configuration to SSO')
[IO.File]::AppendAllText($logFile, [Environment]::NewLine)

[Reflection.Assembly]::Load('SSOConfig, Version=1.0.0.0, Culture=neutral, PublicKeyToken=656a499478affdaf')
$configPath = [String]::Format('{0}\{1}', $env:BTAD_InstallDir, 'Deployment\Sixeyed.CacheAdapter.ssoconfig')
$app = [SSOConfig.SSOApplication]::LoadFromXml($configPath)
$app.SaveToSSO()

[IO.File]::AppendAllText($logFile, [String]::Format('Installation completed: {0}', [DateTime]::Now))